<?php
$conn=mysql_connect('localhost','root','') or die('Á¬½ÓÊ§°Ü£¡'.mysql_error());
mysql_select_db('xzpf',$conn) or die('Êý¾Ý¿âÑ¡ÔñÊ§°Ü:' . mysql_error());
mysql_query("set names utf8;"); //**ÉèÖÃ×Ö·û¼¯***
date_default_timezone_set('Asia/Shanghai');
error_reporting(0);

$query = mysql_query("select shopid,goodsid from goods where zixilie=''");
while ($row = mysql_fetch_assoc($query)) {
	$sql = mysql_query(" SELECT * FROM zifenlei WHERE id IN (SELECT zileimu FROM shop WHERE shopid = ".$row['shopid'].")");
	$result = array();
	while ($row1 = mysql_fetch_assoc($sql)) {
		$result[] = $row1;
	}
	$len = count($result);
	var_dump($len);
	if ($len == 1) {
		$sql = "UPDATE goods set zixilie=".$result[0]['id']." where goodsid=".$row['goodsid']."";
		var_dump($sql);
		$sql = mysql_query($sql);
	}
	

}